**Figures and Tables in Appendix
cd "/Users/chengzhengquan/Desktop/globalization"
use wvs_data.dta, clear

**********************************************************************
**Figure S1
local country "Argentina Armenia Australia Azerbaijan Belarus Brazil Chile China Colombia Cyprus Germany Algeria Ecuador EgyptArabRep Estonia Georgia Ghana HongKongSARChina Haiti India Iraq Jordan Japan Kazakhstan KyrgyzRepublic KoreaRep Kuwait Lebanon Libya Mexico"

foreach y in `country'{
preserve
keep if country_name == "`y'"
qui hist prosocial, xtitle("") ytitle("") discrete ///
     percent fcolor(gs8) lcolor(gs3) ///
	 xlabel(1(1)6) legend(off) ///
     title("`y'") scheme(s1mono) name(`y', replace) 
restore
}
grc1leg `country', ///
        position(6) graphregion(color(white)) ///
        xsize(7) rows(5) legendfrom() ///
		scheme(s1mono) name(country1,replace)
graph save country1, replace
		
local country "Malaysia Nigeria Netherlands NewZealand Pakistan Peru Philippines Poland WestBankandGaza Qatar Romania RussianFederation Rwanda Singapore Slovenia Sweden Thailand TrinidadandTobago Tunisia Turkey Ukraine Uruguay UnitedStates Uzbekistan YemenRep SouthAfrica Zimbabwe"

foreach y in `country'{
preserve
keep if country_name == "`y'"
qui hist prosocial, xtitle("") ytitle("") discrete ///
     percent fcolor(gs8) lcolor(gs3) ///
	 xlabel(1(1)6) legend(off) ///
     title("`y'") scheme(s1mono) name(`y', replace) 
restore
}
grc1leg `country', ///
        position(6) graphregion(color(white)) ///
        xsize(7) rows(5) legendfrom() ///
		scheme(s1mono) name(country2,replace)
graph save country2, replace

**********************************************************************
**Table S1
todummy age_g, values(1 \ 2 \ 3 \ 4 \ 5 \ 6) gen(age1 age2 age3 age4 age5 age6)
todummy education, values(1 \ 2 \ 3) gen(Primary Secondary Tertiary)
todummy marital, values(1 \ 2 \ 3) gen(Spouse N_Spouse Single)
todummy child, values(0 \ 1) gen(childless child_yes)
todummy employment, values(0 \ 1) gen(jobless job)
todummy social_class, values(1 \ 2 \ 3 \ 4 \ 5) gen(Top Fourth Middle Second Poorest)
todummy income, values(1 \ 2 \ 3 \ 4 \ 5) gen(income1 income2 income3 income4 income5)

preserve
global y "prosocial"
global x "tariff_w"
global mech "inequality zero_sum luck_belief"
global control "female age age1 age2 age3 age4 age5 age6 Primary Secondary Tertiary Spouse N_Spouse Single child_yes job Top Fourth Middle Second Poorest income1 income2 income3 income4 income5"
qui reg $y $x $mech $control
keep if e(sample)
qui asdoc tabstat $y $x $mech $control, statistics(N mean sd min max) format(%9.3f) /// 
									title(Summary statistics of main variables) /// 
									save(Table_S1.doc) replace
restore

**********************************************************************
**Table S2
global control "female age i.age_g i.education i.marital i.child i.employment i.social_class i.income i.year"
preserve
qui reg prosocial lntw $control $macro $fe
keep if e(sample)

qui reg prosocial lntw, cluster(countrycode)
qui estimates store ols1

qui reg prosocial lntw $control, cluster(countrycode)
qui estimates store ols2

qui reg prosocial lntw $control gdp, cluster(countrycode)
qui estimates store ols3

outreg2 [ols*] using Table_S2.doc, word replace se dec(3)
restore

**********************************************************************
**Table S3
qui reg prosocial lnts $control, cluster(countrycode)
qui estimates store simple

qui reg prosocial import $control, cluster(countrycode)
qui estimates store import

qui reg prosocial export $control, cluster(countrycode)
qui estimates store export

outreg2 [simple import export] using Table_S3.doc, word replace se dec(3)

**********************************************************************
**Table S4
preserve
use GPS_data.dta, clear
local control "c.age i.gender i.subj_math_skills"

qui reg altruism lntw `control', cluster(region)
qui estimates store tariff_w

qui reg altruism lnts `control', cluster(region)
qui estimates store tariff_s

qui reg altruism import `control', cluster(region)
qui estimates store import

qui reg altruism export `control', cluster(region)
qui estimates store export

outreg2 [tariff_w tariff_s import export] using Table_S4.doc, word replace se dec(3)
restore

**********************************************************************
**Table S5
preserve
use ess_data.dta, clear
global control "female age i.education i.income_feeling"
global fe "i.country_id i.year"
global cluster "i.country_id##i.year"

qui reghdfe help lntw $control, a($fe) vce(cluster $cluster)
qui estimates store tariff_w

qui reghdfe help lnts $control, a($fe) vce(cluster $cluster)
qui estimates store tariff_s

qui reghdfe help import $control, a($fe) vce(r)
qui estimates store import

qui reghdfe help export $control, a($fe) vce(cluster $cluster)
qui estimates store export

outreg2 [tariff_w tariff_s import export] using Table_S5.doc, word replace se dec(3)
restore

**********************************************************************
**Table S6
preserve
use wvs_data.dta, clear

local var "prosocial inequality zero_sum luck_belief"
foreach i in `var'{
	bys year country_id : egen `i'_m = mean(`i')
}
duplicates drop year country_id, force
keep year countrycode country_id *_m lntw

local mech "inequality zero_sum luck_belief"
foreach y in `mech'{
	
	qui reg `y'_m lntw i.year, cluster(country_id)
	qui estimates store `y'
}
outreg2 [inequality zero_sum luck_belief] using Table_S6.doc, word replace se dec(3)
restore

**********************************************************************
**Table S7
preserve
use wvs_data.dta, clear

global control "female age i.age_g i.education i.marital i.child i.employment i.social_class i.income i.year"
local mech "inequality zero_sum luck_belief"
foreach y in `mech'{
	
	qui reg `y' lntw $control, cluster(country_id)
	qui estimates store `y'
}
outreg2 [inequality zero_sum luck_belief] using Table_S7.doc, word replace se dec(3)
restore

**********************************************************************
**Table S8
preserve
use wvs_data.dta, clear

local var "prosocial inequality zero_sum luck_belief"
foreach i in `var'{
	bys year country_id : egen `i'_m = mean(`i')
}
duplicates drop year country_id, force
keep year countrycode country_id *_m lntw

local mech "inequality_m zero_sum_m luck_belief_m"
qui reg prosocial_m lntw i.year, cluster(country_id)
qui estimates store No_mech

foreach y in `mech'{
	qui reg prosocial_m lntw `y' i.year, cluster(country_id)
	qui estimates store `y'
}
outreg2 [No_mech `mech'] using Table_S8.doc, word replace se dec(3)
restore

**********************************************************************
**Table S9
preserve
use wvs_data.dta, clear
global control "female age i.age_g i.education i.marital i.child i.employment i.social_class i.income i.year"

qui reg prosocial lntw $control, cluster(country_id)
qui estimates store No_mech

local mech "inequality zero_sum luck_belief"
foreach y in `mech'{
	qui reg prosocial lntw `y' $control, cluster(country_id)
	qui estimates store `y'
}

outreg2 [No_mech `mech'] using Table_S9.doc, word replace se dec(3)
restore

**********************************************************************
**Table S10
preserve
use wvs_data.dta, clear
global control "female age i.age_g i.education i.marital i.child i.employment i.social_class i.income"

qui reghdfe prosocial lntw $control if rich == 0 , a(year) cluster(countrycode)
qui estimates store poor

qui reghdfe prosocial lntw $control if rich == 1 , a(year) cluster(countrycode)
qui estimates store rich

qui reghdfe prosocial c.lntw##i.rich $control , a(year) cluster(countrycode)
qui estimates store all

outreg2 [poor rich all] using Table_S10.doc, word replace se dec(3)

**********************************************************************
**Table S11
qui reghdfe prosocial lntw $control if high_class == 0 , a(year) cluster(countrycode)
qui estimates store low

qui reghdfe prosocial lntw $control if high_class == 1 , a(year) cluster(countrycode)
qui estimates store high

qui reghdfe prosocial c.lntw##i.high_class $control , a(year) cluster(countrycode)
qui estimates store all

outreg2 [low high all] using Table_S11.doc, word replace se dec(3)
restore




